<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Focus and Outcome</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Focus and Outcome' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">assertions</a></li><li><a href="index.html#6">Chapter 6: Rules, Rulebooks and Activities</a></li><li><b>Focus and Outcome</b></li></ul></div>
<p class="purpose">What a rulebook works on, and what it produces.</p>

<ul class="toc"><li><a href="6-fao.html#SP1">&#167;1. Focus</a></li><li><a href="6-fao.html#SP2">&#167;2. Outcome</a></li><li><a href="6-fao.html#SP11">&#167;11. Sentences adding outcomes to rulebooks</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Focus.</b>The "focus" of a rulebook is what it works upon. Some rulebooks are for processing
actions, but others work on an input value. It's not obvious how to represent
action-focused rulebooks in our system of kinds. Two rejected schemes were:
</p>

<ul class="items"><li>(1) Regard them as "nothing-based rulebooks". But then there is no way to tell
from the kind that they are processing actions rather than performing some
other task.
</li><li>(2) Regard them as "stored action-based rulebooks". But quite apart from the
unnatural look of this text, action-focus rulebooks are not really working on
a stored action &mdash; they can only work on the current action being processed.
They actually have no parameter value at all.
</li></ul>
<p class="commentary">And so we end up with a compromise:
</p>

<ul class="items"><li>(3) Regard them as "action-based rulebooks". This looks right to authors, though
it arguably abuses the word "action". But it does mean there is no way to have
a rulebook which actually has <span class="extract"><span class="extract-syntax">K_action_name</span></span> as its focus kind.
</li></ul>
<p class="commentary">People seem okay with this, but it is indeed a compromise. (In Basic Inform,
there are no actions anyway and this whole discussion is moot.) In case this
is ever reformed, the following structure abstracts the focus so that it
could in principle be differently implemented:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">focus</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">focus_kind</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">focus</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">FocusAndOutcome::action_focus</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::action_focus</span></span>:<br/>Rulebooks - <a href="6-rlb.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">focus</span><span class="plain-syntax"> *</span><span class="identifier-syntax">foc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">foc</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">K_action_name</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">foc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">focus_kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_action_name</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">FocusAndOutcome::get_focus_parameter_kind</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::get_focus_parameter_kind</span></span>:<br/>Rulebooks - <a href="6-rlb.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">focus</span><span class="plain-syntax"> *</span><span class="identifier-syntax">foc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">foc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">focus_kind</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">FocusAndOutcome::initialise_focus</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::initialise_focus</span></span>:<br/>Rulebooks - <a href="6-rlb.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">focus</span><span class="plain-syntax"> *</span><span class="identifier-syntax">foc</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">foc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">focus_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">FocusAndOutcome::focus_on_nothing</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::focus_on_nothing</span></span>:<br/>Rulebooks - <a href="6-rlb.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">focus</span><span class="plain-syntax"> *</span><span class="identifier-syntax">foc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">foc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">focus_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_nil</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure focus is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Outcome.</b>This is more involved. Some rulebooks produce values (and if so, we need to
know what kind), others do not. But they also end in one of an enumerated
range of "outcomes". All rulebooks have the ability to end in success, failure
or with no outcome (which is really an outcome meaning "I was interrupted
and never finished")
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">NO_OUTCOME</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">SUCCESS_OUTCOME</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">FAILURE_OUTCOME</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outcome_kind</span><span class="plain-syntax">; </span><span class="comment-syntax"> of the value produced</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">default_outcome_declared</span><span class="plain-syntax">; </span><span class="comment-syntax"> has the author declared one?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">default_rule_outcome</span><span class="plain-syntax">; </span><span class="comment-syntax"> one of the three </span><span class="extract"><span class="extract-syntax">*_OUTCOME</span></span><span class="comment-syntax"> values above...</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">default_named_outcome</span><span class="plain-syntax">; </span><span class="comment-syntax"> ...or a named alternative</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">named_outcomes</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">rulebook_outcome</span></span><span class="comment-syntax">: other possibilities</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">outcomes</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure outcomes is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>The source text can also have a rulebook end, say, "in a blaze of glory", or give
it other possible endings. Those, if any, are listed in the <span class="extract"><span class="extract-syntax">named_outcomes</span></span>.
Note that they still have to count as failures, successes or not.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outcome_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_of_outcome</span><span class="plain-syntax">; </span><span class="comment-syntax"> one of the three </span><span class="extract"><span class="extract-syntax">*_OUTCOME</span></span><span class="comment-syntax"> values abov</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure rulebook_outcome is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>And each individual named ending corresponds to one of the following. Note
that the same named ending can be used in multiple rulebooks, and can have
a different <span class="extract"><span class="extract-syntax">kind_of_outcome</span></span> in each; that's why we distinguish the
structures <a href="6-fao.html#SP3" class="internal">rulebook_outcome</a> and <a href="6-fao.html#SP4" class="internal">named_rulebook_outcome</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">noun</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">; </span><span class="comment-syntax"> Name in source text</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">nro_compilation_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">compilation_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure named_rulebook_outcome is accessed in 3/nuor, 3/dbtr, 3/rpr, 4/ass, 5/id, 5/idf, 5/adf, 5/tpf, 5/po, 5/rf, 5/rcd, 6/rls, 6/rlb, 6/act, 6/sv, 7/tc, 7/tbl, 7/eqt and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>That awkward distinction between a <a href="6-fao.html#SP3" class="internal">rulebook_outcome</a> and a <a href="6-fao.html#SP4" class="internal">named_rulebook_outcome</a>
brings us edge cases if a rule has been written for use in one rulebook, but then
has been explicitly listed in another, or is more than one rulebook.
</p>

<p class="commentary">Suppose R belongs to both rulebooks B1 and B2, and suppose it "ends splendidly",
that being a named outcome of both. But now suppose this is a success for B1
and a failure for B2. What do we compile in the body of R's code?
</p>

<p class="commentary">The answer is that go with B1, supposing that one to be the earliest created
rulebook.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax"> *</span><span class="function-syntax">FocusAndOutcome::rbo_from_context</span><span class="plain-syntax">(</span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nro</span><span class="plain-syntax">, </span><span class="reserved-syntax">id_body</span><span class="plain-syntax"> *</span><span class="identifier-syntax">idb</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">idb</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outs</span><span class="plain-syntax"> = </span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::get_outcomes</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="6-bl.html#SP7" class="function-link"><span class="function-syntax">BookingLists::contains_ph</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">, </span><span class="identifier-syntax">idb</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ro</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">ro</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax">, </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">named_outcomes</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ro</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">outcome_name</span><span class="plain-syntax"> == </span><span class="identifier-syntax">nro</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ro</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>And this tests whether there is any obstacle to using <span class="extract"><span class="extract-syntax">nro</span></span> in the body of
phrase <span class="extract"><span class="extract-syntax">idb</span></span>'s code. If a rule ends "splendidly", then that needs to be a valid
ending for all of the rulebooks holding it.
</p>

<p class="commentary">This very similar function returns <span class="extract"><span class="extract-syntax">NULL</span></span> if there's no problem, or the rulebook
causing the difficulty if so.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="function-syntax">FocusAndOutcome::rulebook_not_supporting</span><span class="plain-syntax">(</span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nro</span><span class="plain-syntax">, </span><span class="reserved-syntax">id_body</span><span class="plain-syntax"> *</span><span class="identifier-syntax">idb</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">idb</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outs</span><span class="plain-syntax"> = </span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::get_outcomes</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="6-bl.html#SP7" class="function-link"><span class="function-syntax">BookingLists::contains_ph</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">, </span><span class="identifier-syntax">idb</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">okay</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ro</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">ro</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax">, </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">named_outcomes</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ro</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">outcome_name</span><span class="plain-syntax"> == </span><span class="identifier-syntax">nro</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">okay</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">okay</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>A new rulebook begins with:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">FocusAndOutcome::initialise_outcomes</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::initialise_outcomes</span></span>:<br/>Rulebooks - <a href="6-rlb.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outs</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">def</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">outcome_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_outcome_declared</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_rule_outcome</span><span class="plain-syntax"> = </span><span class="identifier-syntax">def</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_named_outcome</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">named_outcomes</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">FocusAndOutcome::set_default_outcome</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::set_default_outcome</span></span>:<br/>Rulebooks - <a href="6-rlb.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outs</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">def</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_rule_outcome</span><span class="plain-syntax"> = </span><span class="identifier-syntax">def</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">FocusAndOutcome::get_outcome_kind</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::get_outcome_kind</span></span>:<br/>Rulebooks - <a href="6-rlb.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outs</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">outcome_kind</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>Named outcomes are indeed specified only by their names:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax"> *</span><span class="function-syntax">FocusAndOutcome::rbno_by_name</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::rbno_by_name</span></span>:<br/><a href="6-fao.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Lexicon::retrieve</span><span class="plain-syntax">(</span><span class="identifier-syntax">MISCELLANEOUS_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Rvalues::is_CONSTANT_of_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_rulebook_outcome</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Rvalues::to_named_rulebook_outcome</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nro</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nro</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Nouns::new_proper_noun</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">NEUTER_GENDER</span><span class="plain-syntax">, </span><span class="identifier-syntax">ADD_TO_LEXICON_NTOPT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MISCELLANEOUS_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">Rvalues::from_named_rulebook_outcome</span><span class="plain-syntax">(</span><span class="identifier-syntax">nro</span><span class="plain-syntax">), </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">());</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nro</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RTRulebooks::new_nro_compilation_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">nro</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">nro</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>Those nouns can be parsed as follows, and form the constant values of the
slightly odd kind <span class="extract"><span class="extract-syntax">K_rulebook_outcome</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;named-rulebook-outcome&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Lexicon::retrieve</span><span class="plain-syntax">(</span><span class="identifier-syntax">MISCELLANEOUS_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Rvalues::is_CONSTANT_of_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_rulebook_outcome</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        ==&gt; { -, </span><span class="identifier-syntax">Rvalues::to_named_rulebook_outcome</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">) }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">nonterminal</span><span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>And the following adds a new outcome name to a given set of <span class="extract"><span class="extract-syntax">outs</span></span>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">FocusAndOutcome::fresh_outcome</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::fresh_outcome</span></span>:<br/><a href="6-fao.html#SP12_5">&#167;12.5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outs</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">OW</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">koo</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">def</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-tc.html#SP11" class="function-link"><span class="function-syntax">Assertions::Creator::vet_name_for_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OW</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">def</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_named_outcome</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_DefaultNamedOutcomeTwice</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"at most one of the named outcomes from a rulebook can be the default"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"and here we seem to have two."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_outcome_declared</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_DefaultOutcomeAlready</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"the default outcome for this rulebook has already been declared"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"and this is something which can only be done once."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">named_rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nro</span><span class="plain-syntax"> = </span><a href="6-fao.html#SP8" class="function-link"><span class="function-syntax">FocusAndOutcome::rbno_by_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">nro</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ro</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">ro</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax">, </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">named_outcomes</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ro</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">outcome_name</span><span class="plain-syntax"> == </span><span class="identifier-syntax">nro</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_DuplicateOutcome</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"this duplicates a previous assignment of the same outcome"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"and to the same rulebook."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ro</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ro</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">outcome_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">nro</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ro</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_of_outcome</span><span class="plain-syntax"> = </span><span class="identifier-syntax">koo</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">def</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_named_outcome</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ro</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_outcome_declared</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">ro</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook_outcome</span><span class="plain-syntax">, </span><span class="identifier-syntax">outs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">named_outcomes</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. Sentences adding outcomes to rulebooks.</b>Rulebooks do not have properties as such, but the following syntax instead creates
outcomes:
</p>

<blockquote>
    <p>Visibility rules have outcomes there is sufficient light (failure) and there is insufficient light (success).</p>
</blockquote>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="identifier-syntax">outcomes_being_parsed</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">FocusAndOutcome::parse_properties</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">FocusAndOutcome::parse_properties</span></span>:<br/>Assertions - <a href="4-ass.html#SP6_3_18">&#167;6.3.18</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outcomes_being_parsed</span><span class="plain-syntax"> = &amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_outcomes</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;rulebook-property&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>The following Preform grammar, then, parses text such as "outcomes there is
sufficient light (failure) and there is insufficient light (success)" and
modifies <span class="extract"><span class="extract-syntax">outcomes_being_parsed</span></span> accordingly.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;rulebook-property&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">outcome</span><span class="plain-syntax">/</span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-outcome-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">default</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-default-outcome&gt;</span><span class="plain-syntax">  |</span>
<span class="plain-syntax">    ...</span>

<span class="function-syntax">&lt;rulebook-default-outcome&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;rule-outcome&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ...</span>

<span class="function-syntax">&lt;rulebook-outcome-list&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;rulebook-outcome-setting-entry&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-outcome-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;rulebook-outcome-setting-entry&gt;</span>

<span class="function-syntax">&lt;rulebook-outcome-tail&gt;</span>
<span class="plain-syntax">    , </span><span class="identifier-syntax">_and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-outcome-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-outcome-list&gt;</span>

<span class="function-syntax">&lt;rulebook-outcome-setting-entry&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;form-of-named-rule-outcome&gt;</span>

<span class="function-syntax">&lt;form-of-named-rule-outcome&gt;</span>
<span class="plain-syntax">    ... ( </span><span class="function-syntax">&lt;rule-outcome&gt;</span><span class="plain-syntax"> - </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="reserved-syntax">default</span><span class="plain-syntax"> ) |</span>
<span class="plain-syntax">    ... ( </span><span class="function-syntax">&lt;rule-outcome&gt;</span><span class="plain-syntax"> - </span><span class="reserved-syntax">default</span><span class="plain-syntax"> ) |</span>
<span class="plain-syntax">    ... ( </span><span class="function-syntax">&lt;rule-outcome&gt;</span><span class="plain-syntax"> ) |</span>
<span class="plain-syntax">    ... ( ... ) |</span>
<span class="plain-syntax">    ...</span>

<span class="function-syntax">&lt;rule-outcome&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">success</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">failure</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">no</span><span class="plain-syntax"> </span><span class="identifier-syntax">outcome</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12_1" class="paragraph-anchor"></a><b>&#167;12.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make this the rulebook's new default</span><span class="named-paragraph-number">12.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">outcomes_being_parsed</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_outcome_declared</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_DefaultOutcomeTwice</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"the default outcome for this rulebook has already been declared"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"and this is something which can only be done once."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">outcomes_being_parsed</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_outcome_declared</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">outcomes_being_parsed</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">default_rule_outcome</span><span class="plain-syntax"> = </span><span class="identifier-syntax">R</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-fao.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_2" class="paragraph-anchor"></a><b>&#167;12.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_NonOutcomeProperty problem</span><span class="named-paragraph-number">12.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_NonOutcomeProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"the only properties of a rulebook are its outcomes"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"for the time being at least."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-fao.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_3" class="paragraph-anchor"></a><b>&#167;12.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_BadDefaultOutcome problem</span><span class="named-paragraph-number">12.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadDefaultOutcome</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"the default outcome given for the rulebook isn't what I expected"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"which would be one of 'default success', 'default failure' or "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"'default no outcome'."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-fao.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_4" class="paragraph-anchor"></a><b>&#167;12.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_BadOutcomeClarification problem</span><span class="named-paragraph-number">12.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadOutcomeClarification</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"the bracketed clarification isn't what I expected"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"which would be one of '(success)', '(failure)' or '(no outcome)'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">FAILURE_OUTCOME</span><span class="plain-syntax">, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-fao.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_5" class="paragraph-anchor"></a><b>&#167;12.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Adopt this new named rule outcome</span><span class="named-paragraph-number">12.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">OW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;form-of-named-rule-outcome&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">koo</span><span class="plain-syntax"> = </span><span class="identifier-syntax">R</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">def</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">koo</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">100</span><span class="plain-syntax">) { </span><span class="identifier-syntax">koo</span><span class="plain-syntax"> -= </span><span class="constant-syntax">100</span><span class="plain-syntax">; </span><span class="identifier-syntax">def</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><a href="6-fao.html#SP10" class="function-link"><span class="function-syntax">FocusAndOutcome::fresh_outcome</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">outcomes_being_parsed</span><span class="plain-syntax">, </span><span class="identifier-syntax">OW</span><span class="plain-syntax">, </span><span class="identifier-syntax">koo</span><span class="plain-syntax">, </span><span class="identifier-syntax">def</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-fao.html#SP12">&#167;12</a>.</li></ul>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="6-rlb.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-am.html">1</a></li><li class="progresschapter"><a href="2-bv.html">2</a></li><li class="progresschapter"><a href="3-dlr.html">3</a></li><li class="progresschapter"><a href="4-nr.html">4</a></li><li class="progresschapter"><a href="5-id.html">5</a></li><li class="progresscurrentchapter">6</li><li class="progresssection"><a href="6-rls.html">rls</a></li><li class="progresssection"><a href="6-rb.html">rb</a></li><li class="progresssection"><a href="6-bl.html">bl</a></li><li class="progresssection"><a href="6-rlb.html">rlb</a></li><li class="progresscurrent">fao</li><li class="progresssection"><a href="6-act.html">act</a></li><li class="progresssection"><a href="6-sv.html">sv</a></li><li class="progresschapter"><a href="7-tc.html">7</a></li><li class="progresschapter"><a href="8-kpr.html">8</a></li><li class="progressnext"><a href="6-act.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

